import request from 'api/request'

export function getQiniuToken(data) {
  return request({
    url: '/qiniu/token',
    method: 'post',
    data
  })
}

export function uploadImage(file, token) {
  const fileName = file.name
  const param = new FormData()
  param.append('chunk', 0)
  param.append('chunk', 1)
  param.append('file', file, fileName)
  param.append('token', token)
  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: 'https://upload.qiniu.com/',
    method: 'Post',
    data: param
  })
}
